<?php
class AnnonceAction extends Action {
     public function index(){
		R('Index/indexpic');
		$this->gonggao();
		$this->dgnt();
		$this->xjc();
		$this->qt();
		$this->meeting();
		$this->indextongzhi();
		$this->huodongpic();
		$this->huodongword();
		$this->display();
    }
	public function dgnt(){
		$model=M('article');
		$cond['type']='多功能厅';
		$index=$model->where($cond)->order('istop desc')->select();
		$this->assign('dgnt',$index);
	}
	public function xjc(){
		$model=M('article');
		$cond['type']='小剧场';
		$index=$model->where($cond)->order('istop desc')->select();
		$this->assign('xjc',$index);
	}
	public function qt(){
		$model=M('article');
		$cond['type']='其他';
		$index=$model->where($cond)->order('istop desc')->select();
		$this->assign('qt',$index);
	}
	public function meeting(){
		$model=M('article');
		$cond['type']=array('in','国际会议,国内会议');
		$index=$model->where($cond)->order('istop desc')->select();
		$this->assign('meeting',$index);
	}
	public function tongzhi(){
		R('Index/indexpic');
		$this->gonggao();
		$this->tongzhilist();
		$this->tongzhicont();
		$this->display();
	}
	public function huodong(){
		R('Index/indexpic');
		$this->gonggao();
		$this->pic();
		$this->lists();
		$this->display();
	}
	private function pic(){
		$model=M('article');
		$cond['type']='活动动态图片';
		$index=$model->where($cond)->order('istop desc')->select();
		$first=$index[0];
		$this->assign('first',$first);

		$second=array(0=>$index[1],1=>$index[2]);
		$this->assign('second',$second);

		$cond1['type']='活动动态';
		$cond1['image']=array('neq','');
		$index1=$model->where($cond1)->order('istop desc')->select();
		$third=array(0=>$index1[0],1=>$index1[1],2=>$index1[2],3=>$index1[3]);
		for($i=0;$i<count($third);$i++)
		{
			$cond2['id']=$third[$i]['image'];
			$img=$model->where($cond2)->select();
			if($img[0]['image']!='null')
			$third[$i]['image']=$img[0]['image'];
			//dump($third);
		}
		$this->assign('third',$third);
	}
	private function lists(){
		$this->gonggao();
		$cond1['type']='活动动态';
		$cond1['image']=array('eq','');
		$model=M('article');
		$list=$model->where($cond1)->order('istop desc')->select();
		$this->assign('list',$list);
	}
	public function search(){
		R('Index/indexpic');
		$this->gonggao();
		$key=$_POST['sch'];
		$scope=$_POST['type'];
		if($key!='null'){
			$article=M('article');
			import("ORG.Util.Page");//导入分页类
			$cond['title']=array('like','%'.$key.'%');
			$cond['type']=array('like','%'.$scope.'%');
			$index=$article->where($cond)->count();
			$Page = new Page($index,10);//实例化分页类传入总记录数和每页显示的记录数
			$show = $Page->show();//分页显示输出
			$list = $article->where($cond)->order('id DESC')->limit($Page->firstRow.','.$Page->listRows)->select();
			for($i=0;$i<count($list);$i++){
				$list[$i]['pubtime'] = 	date("Y-m-d H:i",$list[$i]['pubtime']);
			}
			$this->assign('list',$list);
			$this->assign('page',$show);//赋值分页输出
			$this->display();
		}else{
			$this->error('请输入关键字！');
		}

	}
	public function article(){
		R('Index/indexpic');
		$this->gonggao();
		$model=M('article');
		$cond['id']=$_GET['id'];
		$index=$model->where($cond)->select();
		if($index[0]['image']!=''){
			$this->assign('image',$index[0]['image']);
			if($index[0]['url']!='')
			$this->assign('url',$index[0]['url']);
		}
		$this->assign('title',$index[0]['title']);
		$this->assign('type',$index[0]['type']);
		$this->assign('content',$index[0]['content']);
		$this->display();
	}
	private function gonggao(){
		$model=M('article');
		$cond['isgonggao']='1';
		$index=$model->where($cond)->limit('0,1')->select();
		$this->assign('gonggao',$index[0]['title']);
	}

	private function indextongzhi(){
		$model=M('article');
		$cond['type']='通知公示';
		//$cond['istop']=1;
		//$index=$model->where($cond)->order('pubtime desc')->select();
		//dump($index);

		//修改
		$index=$model->where($cond)->order('istop DESC')->select();
			//dump($index);
		$this->assign('tongzhi',$index);


		//$this->assign('tongzhi',$index[0]['content']);
	}
	private function huodongpic(){
		$model=M('article');
		$cond['type']='活动动态图片';
		$index=$model->where($cond)->select();
		$this->assign('list',$index);
	}
	private function huodongword(){
		$model=M('article');
		$cond['type']='活动动态';
		$list=$model->where($cond)->order('istop desc')->select();
		for($i=0;$i<count($list);$i++){
			$list[$i]['pubtime'] = 	date("m-d",$list[$i]['pubtime']);
		}
		$this->assign('list1',$list);
	}
	private function tongzhilist(){
		$article=M('article');
		import("ORG.Util.Page");//导入分页类
		$cond['type']='通知公示';
		$index=$article->where($cond)->count();
		$Page = new Page($index,12);//实例化分页类传入总记录数和每页显示的记录数
		$show = $Page->show();//分页显示输出
		$list = $article->where($cond)->order('istop DESC')->limit($Page->firstRow.','.$Page->listRows)->select();
		for($i=0;$i<count($list);$i++){
			$list[$i]['pubtime'] = 	date("Y-m-d H:i",$list[$i]['pubtime']);
		}
		$this->assign('list',$list);
		$this->assign('page',$show);//赋值分页输出
	}
	private function tongzhicont(){
		if($_GET['id']==null){
			$article=M('article');
			$cond['type']='通知公示';
			$index=$article->where($cond)->order('istop DESC')->limit('0,1')->select();
			//dump($index);
			$this->assign('title',$index[0]['title']);
			$this->assign('content',$index[0]['content']);
		}else{
			$article=M('article');
			$cond['type']='通知公示';
			$cond['id']=$_GET['id'];
			$index=$article->where($cond)->select();
			//dump($index);
			$this->assign('title',$index[0]['title']);
			$this->assign('content',$index[0]['content']);
		}
	}
}